package com.tangyuan.controller;


import com.tangyuan.common.result.Result;
import com.tangyuan.model.UserAction;
import com.tangyuan.service.UserActionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 小梁
 * @since 2020-12-03
 */
@RestController
@RequestMapping("/recommend")
public class UserActionController {


    @Autowired
    private UserActionService userActionService;

    @ApiOperation("用户浏览")
    @GetMapping("/view")
    public Result view(UserAction userAction) {
        userAction.setAId(null);
        userActionService.view(userAction);
        return Result.ok();
    }


    @ApiOperation("用户行为")
    @PostMapping("/action")
    public Result<String> action(@RequestHeader Long userId,
                                 @RequestParam Long movieId,
                                 @RequestParam(name = "grade",required = false) Float grade,
                                 @RequestParam(name = "collection",required = false) Float collection,
                                 @RequestParam(name = "thump",required = false) Float thump) {
        return userActionService.getUserAction(userId,movieId,grade,collection,thump);
    }
}

